package com.example.finalsystem.Dao;

import com.example.finalsystem.Entity.Deal;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DealMapper {

    @Select("select * from `uml_deal` where dealid = #{dealId}")
    Deal getDealByDealId(String dealId);


    @Select("select * from `uml_deal` where dealid = #{dealId}")
    @Results({
            @Result(property = "listGoods",column = "dealId",
                    many = @Many(select = "com.example.finalsystem.Dao.ListGoodsMapper.getAllByFK_dealId" ))
    })
    Deal getListGoodsByDeal(String dealId);

    //    根据用户查询所有Deal；
    @Select("select * from `uml_deal` where FK_staffid = #{staffId}")
    List<Deal> findDealByStaffId(String staffId);

    @Select("select * from `uml_deal` where FK_clientId = #{clientId}")
    List<Deal> findDealByClientId(Long clientId);

    @Select("select * from `uml_deal`")
    List<Deal> findAllDeal();


    //    以上为多对一方法
    List<Deal> getListOfDeal(int currentPage,int pageSize);


    int countDeal();

    int deleteByPrimaryKey(String dealid);

    int insert(Deal record);

    int insertSelective(Deal record);

    Deal selectByPrimaryKey(String dealid);

    int updateByPrimaryKeySelective(Deal record);

    int updateByPrimaryKeyWithBLOBs(Deal record);

    int updateByPrimaryKey(Deal record);
}